package cn.le.aopAnnotationDataSource;

import cn.le.aopAnnotationDataSource.dao.JdbcDaoImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by admin on 2017/3/28.
 * 测试动态切换多数据源
 */
public class Test {

    /*
        利用自定义注解,spring提供的多数据源实现方式(AbstractRoutingDataSource),spring aop实现数据源的自动切换
     */
    public static void main(String[] args) {
        ApplicationContext app = new ClassPathXmlApplicationContext("classpath:spring-aopAnotationDataSource.xml");
        JdbcDaoImpl jdbcDao1 = (JdbcDaoImpl) app.getBean("jdbcDao");

        List mstartList = jdbcDao1.getMasterFirm();
       // System.out.println(mstartList.toString());
        ///System.out.println(jdbcDao1.getClass().toString());


        //JdbcDao jdbcDao2 = (JdbcDao) app.getBean("jdbcDao");
        // System.out.println(jdbcDao2.getClass().toString());
        List slvarList = jdbcDao1.getSlaveFirm();
       // System.out.println(slvarList.toString());
    }
}
